Release 10.1A: OpenEdge Development:
Progress 4GL Handbook


Running a subprocedure

To run a procedure from within another 4GL procedure, you use the RUN statement. Like the COMPILE statement, the RUN statement has a lot of options, some of which you’ll learn about in later chapters. For now a very simple form of the statement will do:

RUN procedure-name [ (parameters) ]. 

If you are running a procedure file like your h-CustSample.p, then the convention is to include the .p extension in the procedure name. For example, if you bring up a new Procedure Window again, you can enter this statement to run the sample procedure you’ve been working on, then press F2:

This is a little different than just pressing the F2 key in the procedure window where you’re editing h-CustSample.p. When you press F2 or select Compile Run you are compiling and running the current contents of the Procedure Editor window, which might be different from what you have saved to a named file. You can compile and run a procedure without giving it a name at all. Indeed, that’s what you just did: you created a procedure containing a single RUN statement, and then simply compiled and executed it by pressing F2. This temporary procedure in turn ran the named procedure you had already saved and compiled.

Now, why did you put the .p extension on the RUN statement when you have already saved a compiled .r version of the file out to your directory? When you write a 4GL RUN statement with a .p extension on the procedure name, Progress always looks first for a compiled file of the same name, but with the .r extension. If it finds it, it executes it. If it doesn’t, it passes the source file to the Progress compiler, which compiles it on the fly and then executes it. In this way, your application can be a mix of compiled and uncompiled procedures while you’re developing it. If you always use the .p extension in your RUN statements, then your procedures are always found and executed whether they’ve been compiled or not. By contrast, if you specify the .r extension in a RUN statement, then Progress looks for only the compiled .r file, and the RUN fails if it isn’t found.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095